package com.zuul.gateway.config;

import com.zuul.gateway.filter.MyFilter;
import com.zuul.gateway.filter.RestTemplateFilter;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

@Configuration
public class FilterConfig {

	@Bean
	public MyFilter myFilter() {
		return new MyFilter();
	}


	//请求上下文过滤器配置
    @Bean
    public RestTemplateFilter restTemplateFilter(RestTemplate restTemplate) {
        return new RestTemplateFilter(restTemplate); // 注入RestTemplate
    }

    //请求上下文过滤器配置
    @LoadBalanced
    @Bean
    public RestTemplate getRestTemplate() {
        return new RestTemplate();
    }


    //异常过滤器配置
    @Bean
    public ExceptionFilter exceptionFilter() {
        return new ExceptionFilter();
    }



}
